home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-01-24 | 9.8 KB | 591 lines | [TEXT/MPS ] |
- ;
- ; File: GXMath.a
- ;
- ; Contains: QuickDraw GX math routine interfaces.
- ;
- ; Version: Technology: Quickdraw GX 1.1
- ; Package: Universal Interfaces 2.2 in “MPW” on ETO #20
- ;
- ; Copyright: © 1984-1995 by Apple Computer, Inc.
- ; All rights reserved.
- ;
- ; Bugs?: If you find a problem with this file, use the Apple Bug Reporter
- ; stack. Include the file and version information (from above)
- ; in the problem description and send to:
- ; Internet: apple.bugs@applelink.apple.com
- ; AppleLink: APPLE.BUGS
- ;
- ;
-
- IF &TYPE('__GXMATH__') = 'UNDEFINED' THEN
- __GXMATH__ SET 1
-
-
- IF &TYPE('__CONDITIONALMACROS__') = 'UNDEFINED' THEN
- include 'ConditionalMacros.a'
- ENDIF
-
- IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
- include 'Types.a'
- ENDIF
-
- IF &TYPE('__FIXMATH__') = 'UNDEFINED' THEN
- include 'FixMath.a'
- ENDIF
- mathTypesIncludes: SET 1
- gxPoint RECORD 0
- x ds.l 1 ; offset: $0 (0)
- y ds.l 1 ; offset: $4 (4)
- sizeof EQU * ; size: $8 (8)
- ENDR
-
- ; typedef struct gxPoint gxPoint
- ; typedef unsigned short gxColorValue
- gxPolar RECORD 0
- radius ds.l 1 ; offset: $0 (0)
- angle ds.l 1 ; offset: $4 (4)
- sizeof EQU * ; size: $8 (8)
- ENDR
-
- gxMapping RECORD 0
- map ds.l 9 ; offset: $0 (0)
- sizeof EQU * ; size: $24 (36)
- ENDR
-
- ; typedef struct gxPolar gxPolar
- ; typedef struct gxMapping gxMapping
-
- gxColorValue1 EQU $0000FFFF ; gxColorValue 1.0
-
- gxPositiveInfinity EQU $7FFFFFFF ; for Fixed and Fract
- gxNegativeInfinity EQU $80000000 ; for Fixed and Fract
-
- mathRoutinesIncludes: SET 1
- ;
- ; gxMapping *CopyToMapping(gxMapping *target, const gxMapping *source)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _CopyToMapping
- move.w #$31,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION CopyToMapping
- ENDIF
-
- ;
- ; gxMapping *InvertMapping(gxMapping *target, const gxMapping *source)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _InvertMapping
- move.w #$32,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION InvertMapping
- ENDIF
-
- ;
- ; gxMapping *MapMapping(gxMapping *target, const gxMapping *source)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MapMapping
- move.w #$33,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MapMapping
- ENDIF
-
- ;
- ; gxMapping *MoveMapping(gxMapping *target, Fixed hOffset, Fixed vOffset)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MoveMapping
- move.w #$34,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MoveMapping
- ENDIF
-
- ;
- ; gxMapping *MoveMappingTo(gxMapping *target, Fixed hPosition, Fixed vPosition)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MoveMappingTo
- move.w #$35,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MoveMappingTo
- ENDIF
-
- ;
- ; gxMapping *NormalizeMapping(gxMapping *target)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _NormalizeMapping
- move.w #$36,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION NormalizeMapping
- ENDIF
-
- ;
- ; gxMapping *RotateMapping(gxMapping *target, Fixed angle, Fixed xCenter, Fixed yCenter)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _RotateMapping
- move.w #$37,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION RotateMapping
- ENDIF
-
- ;
- ; gxMapping *ScaleMapping(gxMapping *target, Fixed hFactor, Fixed vFactor, Fixed xCenter, Fixed yCenter)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _ScaleMapping
- move.w #$38,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION ScaleMapping
- ENDIF
-
- ;
- ; gxMapping *ResetMapping(gxMapping *target)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _ResetMapping
- move.w #$39,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION ResetMapping
- ENDIF
-
- ;
- ; gxMapping *SkewMapping(gxMapping *target, Fixed skewX, Fixed skewY, Fixed xCenter, Fixed yCenter)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _SkewMapping
- move.w #$3a,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION SkewMapping
- ENDIF
-
- ;
- ; void MapPoints(const gxMapping *source, long count, gxPoint vector[])
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MapPoints
- move.w #$3b,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MapPoints
- ENDIF
-
- ;
- ; short FirstBit(unsigned long x)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _FirstBit
- move.w #$3c,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION FirstBit
- ENDIF
-
- ;
- ; short WideScale(const wide *source)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _WideScale
- move.w #$3d,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION WideScale
- ENDIF
-
- ;
- ; short LinearRoot(Fixed first, Fixed last, Fract t[])
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _LinearRoot
- move.w #$3e,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION LinearRoot
- ENDIF
-
- ;
- ; short QuadraticRoot(Fixed first, Fixed control, Fixed last, Fract t[])
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _QuadraticRoot
- move.w #$3f,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION QuadraticRoot
- ENDIF
-
- ;
- ; gxPoint *PolarToPoint(const gxPolar *ra, gxPoint *xy)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _PolarToPoint
- move.w #$40,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION PolarToPoint
- ENDIF
-
- ;
- ; gxPolar *PointToPolar(const gxPoint *xy, gxPolar *ra)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _PointToPolar
- move.w #$41,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION PointToPolar
- ENDIF
-
- ;
- ; Fract FractCubeRoot(Fract source)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _FractCubeRoot
- move.w #$42,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION FractCubeRoot
- ENDIF
-
- ;
- ; Fract FractDivide(Fract dividend, Fract divisor)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _FractDivide
- move.w #$43,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION FractDivide
- ENDIF
-
- ;
- ; Fract FractMultiply(Fract multiplicand, Fract multiplier)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _FractMultiply
- move.w #$44,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION FractMultiply
- ENDIF
-
- ;
- ; Fract FractSineCosine(Fixed degrees, Fract *cosine)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _FractSineCosine
- move.w #$45,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION FractSineCosine
- ENDIF
-
- ;
- ; Fract FractSquareRoot(Fract source)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _FractSquareRoot
- move.w #$46,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION FractSquareRoot
- ENDIF
-
- ;
- ; Fixed FixedDivide(Fixed dividend, Fixed divisor)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _FixedDivide
- move.w #$47,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION FixedDivide
- ENDIF
-
- ;
- ; Fixed FixedMultiply(Fixed multiplicand, Fixed multiplier)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _FixedMultiply
- move.w #$48,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION FixedMultiply
- ENDIF
-
- ; This next call is (source * multiplier / divisor) -- it avoids underflow, overflow by using wides
- ;
- ; long MultiplyDivide(long source, long multiplier, long divisor)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _MultiplyDivide
- move.w #$49,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION MultiplyDivide
- ENDIF
-
- ;
- ; unsigned long Magnitude(long deltaX, long deltaY)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _Magnitude
- move.w #$4a,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION Magnitude
- ENDIF
-
- ;
- ; long VectorMultiplyDivide(long count, const long *vector1, long step1, const long *vector2, long step2, long divisor)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _VectorMultiplyDivide
- move.w #$4b,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION VectorMultiplyDivide
- ENDIF
-
- ; wide operations are defined within FixMath.h only for PowerPC
- IF ¬ GENERATINGPOWERPC THEN
- ;
- ; wide *WideAdd(wide *target, const wide *source)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _WideAdd
- move.w #$4c,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION WideAdd
- ENDIF
-
- ;
- ; short WideCompare(const wide *target, const wide *source)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _WideCompare
- move.w #$4d,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION WideCompare
- ENDIF
-
- ;
- ; wide *WideNegate(wide *target)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _WideNegate
- move.w #$4e,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION WideNegate
- ENDIF
-
- ;
- ; wide *WideShift(wide *target, long shift)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _WideShift
- move.w #$4f,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION WideShift
- ENDIF
-
- ;
- ; unsigned long WideSquareRoot(const wide *source)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _WideSquareRoot
- move.w #$50,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION WideSquareRoot
- ENDIF
-
- ;
- ; wide *WideSubtract(wide *target, const wide *source)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _WideSubtract
- move.w #$51,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION WideSubtract
- ENDIF
-
- ;
- ; wide *WideMultiply(long multiplicand, long multiplier, wide *target)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _WideMultiply
- move.w #$52,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION WideMultiply
- ENDIF
-
- ; returns the quotient
- ;
- ; long WideDivide(const wide *dividend, long divisor, long *remainder)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _WideDivide
- move.w #$53,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION WideDivide
- ENDIF
-
- ; quotient replaces dividend
- ;
- ; wide *WideWideDivide(wide *dividend, long divisor, long *remainder)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _WideWideDivide
- move.w #$55,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION WideWideDivide
- ENDIF
-
- ENDIF
- ;
- ; wide *VectorMultiply(long count, const long *vector1, long step1, const long *vector2, long step2, wide *dot)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _VectorMultiply
- move.w #$54,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION VectorMultiply
- ENDIF
-
- ;
- ; unsigned long RandomBits(long count, long focus)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _RandomBits
- move.w #$56,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION RandomBits
- ENDIF
-
- ;
- ; void SetRandomSeed(const wide *seed)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _SetRandomSeed
- move.w #$57,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION SetRandomSeed
- ENDIF
-
- ;
- ; wide *GetRandomSeed(wide *seed)
- ;
- IF ¬ GENERATINGCFM THEN
- Macro
- _GetRandomSeed
- move.w #$58,d0
- dc.w $A832
- EndM
- ELSE
- IMPORT_CFM_FUNCTION GetRandomSeed
- ENDIF
-
- ENDIF ; __GXMATH__
-